package com.gee.spring.boot.starter.opengemini.core.query.segment;

import java.util.ArrayList;
import java.util.stream.Collectors;

import static com.gee.spring.boot.starter.opengemini.core.constant.StrConstant.*;
import static com.gee.spring.boot.starter.opengemini.core.enums.SqlKeyword.GROUP_BY;


/**
 * @author gepengjun
 * @since 2024/4/28 16:15
 */
public class GroupBySegmentList extends ArrayList<GroupBySegment> implements ISqlSegment {

    @Override
    public String getSqlSegment() {
        if (size() > 0){
            return GROUP_BY.getKeyword() + SPACE + this.stream().map(GroupBySegment::getSqlSegment).collect(Collectors.joining(COMMA));
        }
        return EMPTY;
    }
}
